/*if (!requestScreenCapture()) {
    toast("请求截图失败");
    exit();
}
*/

function num() {
    var str = id("bbt").findOne().text();
    log(str);
    str = str.slice(5);
    return Number(str.split("\)")[0]);
}
var i = 1;

var args = engines.myEngine().execArgv;
var appName = args.appName;
var Lrsd = Number(args.Lrsd);
var Yqsd = Number(args.Yqsd);
var Lrrs = Number(args.Lrrs);

app.launchApp(appName);
sleep(500);
id("djh").waitFor();
sleep(500);
click(id("ik5").findOne().bounds());
sleep(300);
back();
sleep(500);
var Hheight = id("atu").findOne().bounds().height();
var Hy = id("atu").findOne().bounds().bottom;
var yhText = id("f5e").findOne().text();
var yhText1 = "不，，we可..dg能ghjj一gubh样";
var i = Lrrs;

while (yhText != yhText1 && i >= 0) {
    yhText = id("f5e").findOne().text();
    var fk = id("axa").find().find(checked(false));
    for (var fkl = 0; fk.length > fkl;) {
        if (i > 0) {
            click(fk[fkl].parent().bounds());
            i--;
            fkl++;
        } else if (i == 0) {
            var numJl = num();
            if (numJl == Lrrs)
                break;
            else
                i = Lrrs - numJl;
        }
        sleep(Lrsd);
    }
    if (i >= 0) {
        fk = id("axa").find().find(checked(false));
        for (var fkl = 0; fk.length > fkl; fkl++) {
            click(fk[fkl].parent().bounds());
            sleep(Lrsd);
        }
    }
    sleep(100);
    if (num() == Lrrs)
        break;
    //bounds("(0,593,1080,2145)")
    swipe(647, Hy-1, 647, Hy - Hheight, 200);
    sleep(300);
    yhText1 = id("f5e").findOne().text();
}

var ljyq = id("bbt").findOne().bounds();
sleep(Yqsd);
takeScreenshot();
sleep(Yqsd);

var Time = new Date();
var Year=Time.getFullYear();
var Month=Time.getMonth()+1;
var Day=Time.getDate();
var Hours=Time.getHours();
var Minutes=Time.getMinutes();
var Seconds=Time.getSeconds();
var time="["+Year+"年"+Month+"月"+Day+"日"+Hours+":"+Minutes+":"+Seconds+"]";
var rtext=id("f5e").find();
var saveStr = time+id("ivTitleName").findOne().text() +" ："+ rtext[rtext.length-1].text();
files.createWithDirs("/storage/emulated/0/群and位置.txt");
var saveQ= open("/storage/emulated/0/群and位置.txt","a");


/*id("axa").checked(true).findOne().text();
var name = id("ivTitleName").findOne().text() + ".png";
var path="/storage/emulated/0/Pictures/Screenshots/"+ name;
var img = captureScreen();media.scanFile(path);
images.scanFile(img,  path);*/
click(ljyq);
id("eor").text("群聊成员").waitFor();
back();
sleep(300);
id("mam").waitFor();
while (id("mam").findOne(500)) {
    back();
    sleep(700);
}
id("kbi").text("我的").waitFor();
click(id("kbi").text("我的").findOne().bounds());
var qqName=id("nickname").findOne().text();
saveQ.write(qqName+"："+saveStr+"\n");